package com.bosssoft.user.permission.center.serve.dao.mapper;

import com.bosssoft.user.permission.center.serve.dao.entity.RoleResource;

import com.bosssoft.user.permission.center.serve.pojo.vo.TreeNode;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleResourceMapper {

    Boolean batchDeleteRolesWithResource(@Param("ids") List<Long> ids);



    Boolean batchAllocateResource(@Param("list") List<RoleResource> list);


    List<TreeNode> showSingleRoleResource(@Param("roleId") Long roleId, @Param("tenantId") Long tenantId);

    List<TreeNode> showMultipleRoleResource(@Param("roleIds") List<Long> roleIds,@Param("tenantId") Long tenantId);


    @Delete("DELETE FROM basic_role_resource where role_id = #{roleId}")
    void batchDeleteTheResourcesOfRole(@Param("roleId") Long roleId);

    @Select("select count(*) FROM basic_role_resource WHERE role_id = #{roleId}")
    Integer checkRoleIfHavingResource(@Param("roleId") Long roleId);


}
